package com.springboot.spring01ioc.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
//该修改器可以拦截每一个Bean
@Component
public class MyTestBeanPostProsessor implements BeanPostProcessor {
    //在初始化之前
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcess[Before]Initialization拦截了"+beanName);
        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }
    //在初始化之后
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcess[After]Initialization拦截了"+beanName);
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
